//
//  WYRecommendCell.m
//  CirclePush
//
//  Created by admin on 2018/4/9.
//  Copyright © 2018年 admin. All rights reserved.
//


#import "WYRecommendCell.h"

@interface WYRecommendCell()

@property (strong, nonatomic) IBOutlet UILabel *nameLabel;

@property (strong, nonatomic) IBOutlet UILabel *priceLabel;

@property (strong, nonatomic) IBOutlet UILabel *timeLabel;

@property (strong, nonatomic) IBOutlet UILabel *sendTimeLabel;



@end
@implementation WYRecommendCell


-(void)setMedia:(WYMedia *)media
{
    _media = media;
    [self.companyImageView sd_setImageWithURL:[NSURL URLWithString:media.coverImage] placeholderImage:nil];
    self.nameLabel.text = media.mediaTitle;
    
    if (media.publishPrice.longLongValue/100>10000) {
        if (media.launchCycle.length) {
             self.priceLabel.text =[NSString stringWithFormat:@"%.2f万/%@",media.publishPrice.longLongValue/100/10000.0,media.launchCycle];
        }else{
             self.priceLabel.text =[NSString stringWithFormat:@"%.2f万",media.publishPrice.longLongValue/100/10000.0];
        }
       
    }else{
        if (media.launchCycle.length) {
              self.priceLabel.text =[NSString stringWithFormat:@"%lld/%@",media.publishPrice.longLongValue/100,media.launchCycle];
        }else{
            self.priceLabel.text =[NSString stringWithFormat:@"%lld",media.publishPrice.longLongValue/100];
        }
        
        
       
    }
    
    
    
    self.timeLabel.text = [self getDate:media.createTime WithDate:@"yyyy-MM-dd HH:mm:ss"];
    self.sendTimeLabel.text = [NSString stringWithFormat:@"投放时间:%@~%@",[self getDate:media.launchTime WithDate:@"yyyy-MM-dd"],[self getDate:media.launchEndTime WithDate:@"yyyy-MM-dd"]];
}

-(NSString *)getDate:(NSString *)timeStampString WithDate:(NSString *)formater
{
    //@"yyyy-MM-dd HH:mm:ss"
    NSTimeInterval interval    =[timeStampString doubleValue] / 1000.0;
    NSDate *date               = [NSDate dateWithTimeIntervalSince1970:interval];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:formater];
    return [formatter stringFromDate:date];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
